import {mapGetters} from "vuex";
import {getUserList,
  listBrand,//品牌
  listConfig,//配置信息
  listGoodsType,//物品类型
  listHandler,//处置方
  listSpec,//规格型号
  listStaff,//员工
  listStock,//存放位置
  listSupplier,//供应商
  listUnit//单位
} from "@/api/searchQueryInput";
import {listTreeAssetInformation} from '@/api/famfrontend/masterData/masterData';

export const searchQueryInputMixin = {
  data() {
    return {
        popVisible:false,
      searchInputDataList: [],
      searchInputValue: "",
      searchInputSize: "small",
      searchInputDebounce: 1000,
      searchInputValueKey: "name",
      searchInputType: "",
      searchInputSelectData: null,
      searchInputGoodsTypeName: "",
      searchInputGoodsTypeId: "",
      searchInputTreeFilterText: '',
      searchInputTreeData: [],
      searchInputTreeDefaultProps: {
        children: 'children',
        // label: 'label',
        // label: 'typeName',
        label: 'value',
      },
      searchInputTreeCheckData: [],
      searchInputTreeCheckType:"",
      searchInputTreeFormName:"",
      searchFormTypeName:"",
      isUpdate:true,
    }
  },
  created() {
    // console.log("searchQueryInput-created")
    // this.listGoodsTypeTreeData()
  },
  watch: {
    searchInputValue(val){
      console.log("searchInputValue",val)
    },
    searchInputTreeFilterText(val) {
      this.$refs.searchInputTree.filter(val);
    },

  },
  computed: {
    ...mapGetters(["userInfo"])
  },
  methods:{
    querySearchInputAsyncAssets(queryString, cb){
      if(this.searchInputType=="供应商"){
        this.searchInputValueKey="supplierName"
        // 供应商
          let obj={
            supplierName:queryString,
            isHasAsset:true,
          }
          listSupplier(obj).then(res => {
            const data = res.data.data;
            this.searchInputDataList = data;
            cb(data)
          });
      }
    },
    querySearchInputAsync(queryString, cb) {
      // console.log("queryString",queryString)

      if(this.searchInputType=="品牌"){
        this.searchInputValueKey="brandName"
        this.listBrand(queryString, cb)
      }else if(this.searchInputType=="配置信息"){
        this.searchInputValueKey="configName"
        // if(this.searchInputGoodsTypeId){
        //   this.listConfig(queryString, cb)
        // }else{
        //   cb([])
        // }
        this.listConfig(queryString, cb)
      }else if(this.searchInputType=="物品类型"){
        this.searchInputValueKey="typeName"
        this.listGoodsType(queryString, cb, "")
      }else if(this.searchInputType=="物品类型-资产"){
        this.searchInputValueKey="typeName"
        this.listGoodsType(queryString, cb, "1000")
      }else if(this.searchInputType=="物品类型-耗材"){
        this.searchInputValueKey="typeName"
        this.listGoodsType(queryString, cb, "1001")
      }else if(this.searchInputType=="处置方"){
        this.searchInputValueKey="handlerName"
        this.listHandler(queryString, cb)
      }else if(this.searchInputType=="规格型号"){
        this.searchInputValueKey="specName"
        // if(this.searchInputGoodsTypeId){
        //   this.listSpec(queryString, cb)
        // }else{
        //   cb([])
        // }
        this.listSpec(queryString, cb)
      }else if(this.searchInputType=="员工"){
        this.searchInputValueKey="staffName"
        this.listStaff(queryString, cb)
      }else if(this.searchInputType=="存放位置"){
        this.searchInputValueKey="stockName"
        this.listStock(queryString, cb)
      }else if(this.searchInputType=="供应商"){
        this.searchInputValueKey="supplierName"
        this.listSupplier(queryString, cb)
      }else if(this.searchInputType=="单位"){
        this.searchInputValueKey="unitName"
        this.listUnit(queryString, cb)
      }else{
        this.searchInputValueKey=""
        cb([])
      }
    },
    searchInputSelect(item) {
      // console.log("searchInputSelect",this.searchInputType,item);
      // console.log("searchInputValue",this.searchInputValue)
      this.searchInputSelectData=item;

      if(this.searchInputType.indexOf("物品类型") > -1){
        this.searchInputGoodsTypeId=item.id
        this.searchInputGoodsTypeName=item.typeName
        if(this.listGoodsTypeBackFun){
          this.listGoodsTypeBackFun()
        }
        if(this.searchForm){
          this.searchForm.typeId=item.id
        }
        if(this.dialogForm){
          this.dialogForm.typeId=item.id
        }
        if(this.inFoForm){
          this.inFoForm.typeId=item.id
        }
        if(this.outsideDialogDialogForm){
          this.outsideDialogDialogForm.typeId=item.id
        }
      }else if(this.searchInputType=="品牌"){
        if(this.searchForm){
          this.searchForm.brandId=item.id
        }
        if(this.dialogForm){
          this.dialogForm.brandId=item.id
        }
        if(this.inFoForm){
          this.inFoForm.brandId=item.id
        }
        if(this.outsideDialogDialogForm){
          this.outsideDialogDialogForm.brandId=item.id
        }
      }else if(this.searchInputType=="单位"){
        if(this.searchForm){
          this.searchForm.unitId=item.id
        }
        if(this.dialogForm){
          this.dialogForm.unitId=item.id
        }
        if(this.inFoForm){
          this.inFoForm.unitId=item.id
        }
        if(this.outsideDialogDialogForm){
          this.outsideDialogDialogForm.unitId=item.id
        }
      }else if(this.searchInputType=="规格型号"){
        if(this.searchForm){
          this.searchForm.specId=item.id
        }
        if(this.dialogForm){
          this.dialogForm.specId=item.id
        }
        if(this.inFoForm){
          this.inFoForm.specId=item.id
        }
        if(this.outsideDialogDialogForm){
          this.outsideDialogDialogForm.specId=item.id
        }
      }else if(this.searchInputType=="配置信息"){
        if(this.searchForm){
          this.searchForm.configId=item.id
        }
        if(this.dialogForm){
          this.dialogForm.configId=item.id
        }
        if(this.inFoForm){
          this.inFoForm.configId=item.id
        }
        if(this.outsideDialogDialogForm){
          this.outsideDialogDialogForm.configId=item.id
        }
      }else if(this.searchInputType=="供应商"){
        if(this.searchForm && this.searchForm.supplierId != undefined){
          this.searchForm.supplierId=item.id
        }
        if(this.dialogForm && this.dialogForm.supplierId != undefined){
          this.dialogForm.supplierId=item.id
        }
        if(this.inFoForm && this.inFoForm.supplierId != undefined){
          this.inFoForm.supplierId=item.id
        }
        if(this.insideSearchForm && this.insideSearchForm.supplierId != undefined){
          this.insideSearchForm.supplierId=item.id
        }
        if(this.Form && this.Form.supplierId != undefined){
          this.Form.supplierId=item.id
        }
        if(this.outsideDialogSearchForm && this.outsideDialogSearchForm.supplierId != undefined){
          this.outsideDialogSearchForm.supplierId=item.id
        }
      }else if(this.searchInputType=="处置方"){
        if(this.searchForm && this.searchForm.handlerId != undefined){
          this.searchForm.handlerId=item.id
        }
        if(this.dialogForm && this.dialogForm.handlerId != undefined){
          this.dialogForm.handlerId=item.id
        }
        if(this.Form && this.Form.handlerId != undefined){
          this.Form.handlerId=item.id
        }
      }

    },
    // 测试接口
    getSearchInputList(queryString, cb) {
      let obj={
        current:1,
        size:20,
        account:queryString
      }
      getUserList(obj).then(res => {
        const data = res.data.data;
        let list = data.records;
        this.searchInputDataList = list;
        cb(list)
      });
    },
    //autocomplete 验证手动输入的品牌是否存在
    changeBrandName(val){
      listBrand().then(res => {
        let allBrandName=[];
        for (let i = 0; i < res.data.data.length; i++) {
          allBrandName.push(res.data.data[i].brandName);
        }
        // if(allBrandName.indexOf(val)===-1){
        //   this.dialogForm.brandName='';
        //   this.$message.warning('暂无该品牌');
        // }
      })
    },
    //autocomplete 验证手动输入的单位是否存在
    changeUnitName(val){
      listUnit().then(res => {
        let allUnitName=[];
        for (let i = 0; i < res.data.data.length; i++) {
          allUnitName.push(res.data.data[i].unitName);
        }
        // if(allUnitName.indexOf(val)===-1){
        //   this.dialogForm.unitName='';
        //   this.$message.warning('暂无该单位');
        // }
      })
    },
    searchInputChange(val){
      // console.log("searchInputChange",val)
      if(!val){
        this.searchInputSelectData = null
        if(this.searchInputType.indexOf("物品类型") > -1){
          if(this.listGoodsTypeClearFun){
            this.searchInputGoodsTypeId=""
            this.searchInputGoodsTypeName=""
            this.listGoodsTypeClearFun()
            // if(this.searchForm){
            //   this.searchForm.specId = '';
            //   this.searchForm.specName = '';
            //   this.searchForm.configId = '';
            //   this.searchForm.configName = '';
            // }
            // if(this.dialogForm){
            //   this.dialogForm.specId = '';
            //   this.dialogForm.specName = '';
            //   this.dialogForm.configId = '';
            //   this.dialogForm.configName = '';
            // }
            // if(this.inFoForm){
            //   this.inFoForm.specId = '';
            //   this.inFoForm.specName = '';
            //   this.inFoForm.configId = '';
            //   this.inFoForm.configName = '';
            // }
          }
          if(this.searchForm && this.searchForm.typeName != undefined){
            this.searchForm.typeName=""
            this.searchForm.typeId=""
          }
          if(this.dialogForm && this.dialogForm.typeName != undefined){
            this.dialogForm.typeName=""
            this.dialogForm.typeId=""
          }
          if(this.inFoForm && this.inFoForm.typeName != undefined){
            this.inFoForm.typeName=""
            this.inFoForm.typeId=""
          }
          if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.typeName != undefined){
            this.outsideDialogDialogForm.typeName=""
            this.outsideDialogDialogForm.typeId=""
          }
        }else if(this.searchInputType=="品牌"){
          if(this.searchForm && this.searchForm.brandName != undefined){
            this.searchForm.brandName=""
            this.searchForm.brandId=""
          }
          if(this.dialogForm && this.dialogForm.brandName != undefined){
            this.dialogForm.brandName=""
            this.dialogForm.brandId=""
          }
          if(this.inFoForm && this.inFoForm.brandName != undefined){
            this.inFoForm.brandName=""
            this.inFoForm.brandId=""
          }
          if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.brandName != undefined){
            this.outsideDialogDialogForm.brandName=""
            this.outsideDialogDialogForm.brandId=""
          }
        }else if(this.searchInputType=="规格型号"){
          if(this.searchForm && this.searchForm.specName != undefined){
            this.searchForm.specName=""
            this.searchForm.specId=""
          }
          if(this.dialogForm && this.dialogForm.specName != undefined){
            this.dialogForm.specName=""
            this.dialogForm.specId=""
          }
          if(this.inFoForm && this.inFoForm.specName != undefined){
            this.inFoForm.specName=""
            this.inFoForm.specId=""
          }
          if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.specName != undefined){
            this.outsideDialogDialogForm.specName=""
            this.outsideDialogDialogForm.specId=""
          }
        }else if(this.searchInputType=="单位"){
          if(this.searchForm && this.searchForm.unitName != undefined){
            this.searchForm.unitName=""
            this.searchForm.unitId=""
          }
          if(this.dialogForm && this.dialogForm.unitName != undefined){
            this.dialogForm.unitName=""
            this.dialogForm.unitId=""
          }
          if(this.inFoForm && this.inFoForm.unitName != undefined){
            this.inFoForm.unitName=""
            this.inFoForm.unitId=""
          }
        }else if(this.searchInputType=="配置信息"){
          if(this.searchForm && this.searchForm.configName != undefined){
            this.searchForm.configName=""
            this.searchForm.configId=""
          }
          if(this.dialogForm && this.dialogForm.configName != undefined){
            this.dialogForm.configName=""
            this.dialogForm.configId=""
          }
          if(this.inFoForm && this.inFoForm.configName != undefined){
            this.inFoForm.configName=""
            this.inFoForm.configId=""
          }
          if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.configName != undefined){
            this.outsideDialogDialogForm.configName=""
            this.outsideDialogDialogForm.configId=""
          }
        }else if(this.searchInputType=="供应商"){
          if(this.searchForm && this.searchForm.supplierName != undefined){
            this.searchForm.supplierName=""
            this.searchForm.supplierId=""
          }
          if(this.dialogForm && this.dialogForm.supplierName != undefined){
            this.dialogForm.supplierName=""
            this.dialogForm.supplierId=""
          }
          if(this.inFoForm && this.inFoForm.supplierName != undefined){
            this.inFoForm.supplierName=""
            this.inFoForm.supplierId=""
          }
          if(this.insideSearchForm && this.insideSearchForm.supplierName != undefined){
            this.insideSearchForm.supplierName=""
            this.insideSearchForm.supplierId=""
          }
          if(this.Form && this.Form.supplierName != undefined){
            this.Form.supplierName=""
            this.Form.supplierId=""
          }
          if(this.outsideDialogSearchForm && this.outsideDialogSearchForm.supplierName != undefined){
            this.outsideDialogSearchForm.supplierName=""
            this.outsideDialogSearchForm.supplierId=""
          }
        }else if(this.searchInputType=="处置方"){
          if(this.searchForm && this.searchForm.handlerName != undefined){
            this.searchForm.handlerName=""
            this.searchForm.handlerId=""
          }
          if(this.dialogForm && this.dialogForm.handlerName != undefined){
            this.dialogForm.handlerName=""
            this.dialogForm.handlerId=""
          }
          if(this.Form && this.Form.handlerName != undefined){
            this.Form.handlerName=""
            this.Form.handlerId=""
          }
        }
      }


    },
    searchInputClear(type){
      // console.log("searchInputClear",type)
      this.searchInputSelectData = null
      if(type.indexOf("物品类型") > -1){
        if(this.searchForm && this.searchForm.typeName != undefined){
          this.searchForm.typeName=""
          this.searchForm.typeId=""
        }
        if(this.dialogForm && this.dialogForm.typeName != undefined){
          this.dialogForm.typeName=""
          this.dialogForm.typeId=""
        }
        if(this.inFoForm && this.inFoForm.typeName != undefined){
          this.inFoForm.typeName=""
          this.inFoForm.typeId=""
        }
        if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.typeName != undefined){
          this.outsideDialogDialogForm.typeName=""
          this.outsideDialogDialogForm.typeId=""
        }
      }else if(type=="品牌"){
        if(this.searchForm && this.searchForm.brandName != undefined){
          this.searchForm.brandName=""
          this.searchForm.brandId=""
        }
        if(this.dialogForm && this.dialogForm.brandName != undefined){
          this.dialogForm.brandName=""
          this.dialogForm.brandId=""
        }
        if(this.inFoForm && this.inFoForm.brandName != undefined){
          this.inFoForm.brandName=""
          this.inFoForm.brandId=""
        }
        if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.brandName != undefined){
          this.outsideDialogDialogForm.brandName=""
          this.outsideDialogDialogForm.brandId=""
        }
      }else if(type=="规格型号"){
        if(this.searchForm && this.searchForm.specName != undefined){
          this.searchForm.specName=""
          this.searchForm.specId=""
        }
        if(this.dialogForm && this.dialogForm.specName != undefined){
          this.dialogForm.specName=""
          this.dialogForm.specId=""
        }
        if(this.inFoForm && this.inFoForm.specName != undefined){
          this.inFoForm.specName=""
          this.inFoForm.specId=""
        }
        if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.specName != undefined){
          this.outsideDialogDialogForm.specName=""
          this.outsideDialogDialogForm.specId=""
        }
      }else if(type=="单位"){
        if(this.searchForm && this.searchForm.unitName != undefined){
          this.searchForm.unitName=""
          this.searchForm.unitId=""
        }
        if(this.dialogForm && this.dialogForm.unitName != undefined){
          this.dialogForm.unitName=""
          this.dialogForm.unitId=""
        }
        if(this.inFoForm && this.inFoForm.unitName != undefined){
          this.inFoForm.unitName=""
          this.inFoForm.unitId=""
        }
      }else if(type=="配置信息"){
        if(this.searchForm && this.searchForm.configName != undefined){
          this.searchForm.configName=""
          this.searchForm.configId=""
        }
        if(this.dialogForm && this.dialogForm.configName != undefined){
          this.dialogForm.configName=""
          this.dialogForm.configId=""
        }
        if(this.inFoForm && this.inFoForm.configName != undefined){
          this.inFoForm.configName=""
          this.inFoForm.configId=""
        }
        if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.configName != undefined){
          this.outsideDialogDialogForm.configName=""
          this.outsideDialogDialogForm.configId=""
        }
      }else if(type=="供应商"){
        if(this.searchForm && this.searchForm.supplierName != undefined){
          this.searchForm.supplierName=""
          this.searchForm.supplierId=""
        }
        if(this.dialogForm && this.dialogForm.supplierName != undefined){
          this.dialogForm.supplierName=""
          this.dialogForm.supplierId=""
        }
        if(this.inFoForm && this.inFoForm.supplierName != undefined){
          this.inFoForm.supplierName=""
          this.inFoForm.supplierId=""
        }
        if(this.insideSearchForm && this.insideSearchForm.supplierName != undefined){
          this.insideSearchForm.supplierName=""
          this.insideSearchForm.supplierId=""
        }
        if(this.Form && this.Form.supplierName != undefined){
          this.Form.supplierName=""
          this.Form.supplierId=""
        }
        if(this.outsideDialogSearchForm && this.outsideDialogSearchForm.supplierName != undefined){
          this.outsideDialogSearchForm.supplierName=""
          this.outsideDialogSearchForm.supplierId=""
        }
      }else if(type=="处置方"){
        if(this.searchForm && this.searchForm.handlerName != undefined){
          this.searchForm.handlerName=""
          this.searchForm.handlerId=""
        }
        if(this.dialogForm && this.dialogForm.handlerName != undefined){
          this.dialogForm.handlerName=""
          this.dialogForm.handlerId=""
        }
        if(this.Form && this.Form.handlerName != undefined){
          this.Form.handlerName=""
          this.Form.handlerId=""
        }
      }
    },



    // 品牌
    listBrand(queryString, cb) {
      let obj={
        brandName:queryString
      }
      listBrand(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 配置信息
    listConfig(queryString, cb) {
      let obj={
        configName:queryString,
      }
      listConfig(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 物品类型
    listGoodsType(queryString, cb, goodsCategory) {
      let obj={
        typeName:queryString,
        goodsCategory,// 1000资产, 1001耗材
      }
      listGoodsType(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 处置方
    listHandler(queryString, cb) {
      let obj={
        handlerName:queryString
      }
      listHandler(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 规格型号
    listSpec(queryString, cb) {
      let obj={
        specName:queryString,
      }
      listSpec(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 员工
    listStaff(queryString, cb) {
      let obj={
        staffName:queryString
      }
      listStaff(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 存放位置
    listStock(queryString, cb) {
      let obj={
        stockName:queryString
      }
      listStock(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 供应商
    listSupplier(queryString, cb) {
      let obj={
        supplierName:queryString,
        isHasAsset:false,
      }
      listSupplier(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },
    // 单位
    listUnit(queryString, cb) {
      let obj={
        unitName:queryString
      }
      listUnit(obj).then(res => {
        const data = res.data.data;
        this.searchInputDataList = data;
        cb(data)
      });
    },



    searchInputTreeFilterNode(value, data) {
      if (!value) return true;
      // return data.label.indexOf(value) !== -1;
      // return data.typeName.indexOf(value) !== -1;
      return data.value.indexOf(value) !== -1;
    },
    // 物品类型
    listGoodsTypeTreeData(goodsCategory) {
      // let obj={
      //   typeName:"",
      //   goodsCategory,// 1000资产, 1001耗材
      // }
      // listGoodsType(obj).then(res => {
      //   const data = res.data.data;
      //   console.log("listGoodsTypeTreeData",data)
      //   this.searchInputTreeData = data;
      // });

      let obj={
        goodsCategory,// 1000资产, 1001耗材
      }
      listTreeAssetInformation(obj).then(res => {
        this.searchInputTreeData = res.data.data;
      })
    },
    searchInputTreeClick(data){

      // console.log("searchInputTreeClick",data)
      // if(this.searchInputTreeCheckType=="单选"){
        // this.searchInputTreeFilterText=data.typeName
        // if(this.searchForm && this.searchForm.typeName != undefined){
        //   this.searchForm.typeName=data.typeName
        //   this.searchForm.typeId=data.id
        // }
        // if(this.dialogForm){
        //   this.dialogForm.typeName=data.typeName
        //   this.dialogForm.typeId=data.id
        // }
        // if(this.inFoForm){
        //   this.inFoForm.typeName=data.typeName
        //   this.inFoForm.typeId=data.id
        // }
        // if(this.outsideDialogDialogForm){
        //   this.outsideDialogDialogForm.typeName=data.typeName
        //   this.outsideDialogDialogForm.typeId=data.id
        // }
      // }

      if(this[this.searchInputTreeFormName] && this.searchInputTreeCheckType=="单选"){
        // this[this.searchInputTreeFormName].typeName=data.typeName
        // this[this.searchInputTreeFormName].typeId=data.id
        this[this.searchInputTreeFormName].typeName=data.value
        this[this.searchInputTreeFormName].typeId=data.id

        // this.searchFormTypeName=data.typeName
        this.searchFormTypeName=data.value
      }else{
        if(this[this.searchInputTreeFormName].typeId.indexOf(data.id)===-1){
          this[this.searchInputTreeFormName].typeName.push(data.value)
          this[this.searchInputTreeFormName].typeId.push(data.id)
        }else{
          for (let i=0; i<this[this.searchInputTreeFormName].typeName.length; i++){
            if (this[this.searchInputTreeFormName].typeName[i] == data.value){
              this[this.searchInputTreeFormName].typeName.splice(i, 1)
              this[this.searchInputTreeFormName].typeId.splice(i, 1)
            }
          }
        }
        console.log(this[this.searchInputTreeFormName].typeName)
      }
      this.popVisible = false
      this.$forceUpdate()
    },
    searchTypeTreeClear(){
      // console.log("searchTypeTreeClear")
      if(this.searchForm && this.searchForm.typeName != undefined){
        this.searchForm.typeName=""
        this.searchForm.typeId=""
      }
      if(this.dialogForm && this.dialogForm.typeName != undefined){
        this.dialogForm.typeName=""
        this.dialogForm.typeId=""
      }
      if(this.inFoForm && this.inFoForm.typeName != undefined){
        this.inFoForm.typeName=""
        this.inFoForm.typeId=""
      }
      if(this.outsideDialogDialogForm && this.outsideDialogDialogForm.typeName != undefined){
        this.outsideDialogDialogForm.typeName=""
        this.outsideDialogDialogForm.typeId=""
      }
      this.$refs.searchInputTree.setCheckedKeys([]);
      this.searchInputTreeCheckData=[]
      this.searchFormTypeName=""
    },
    searchTypeTreeChange(val){
      if(!val){
        if(this.searchForm && this.searchInputTreeCheckType=="多选"){
          this.searchForm.typeName=""
          this.searchForm.typeId=""
        }
        if(this.dialogForm && this.searchInputTreeCheckType=="单选"){
          this.dialogForm.typeName=""
          this.dialogForm.typeId=""
        }
        if(this.inFoForm && this.searchInputTreeCheckType=="单选"){
          this.inFoForm.typeName=""
          this.inFoForm.typeId=""
        }
        if(this.outsideDialogDialogForm && this.searchInputTreeCheckType=="单选"){
          this.outsideDialogDialogForm.typeName=""
          this.outsideDialogDialogForm.typeId=""
        }
        this.$refs.searchInputTree.setCheckedKeys([]);
        this.searchInputTreeCheckData=[]
        this.searchFormTypeName=""
      }
    },
    searchInputTreeCheckChange(data){
      this.searchInputTreeCheckData=this.$refs.searchInputTree.getCheckedNodes()
      console.log("searchInputTreeCheckChange",data,this.searchInputTreeCheckData)
      let nameArr=[]
      let idArr=[]
      for (let i = 0; i < this.searchInputTreeCheckData.length; i++) {
        // nameArr.push(this.searchInputTreeCheckData[i].typeName)
        // idArr.push(this.searchInputTreeCheckData[i].id)
        nameArr.push(this.searchInputTreeCheckData[i].value)
        idArr.push(this.searchInputTreeCheckData[i].id)
      }
      if(this.searchForm && this.searchInputTreeCheckType=="多选"){
        this.searchForm.typeName=nameArr.join()
        this.searchForm.typeId=idArr.join()
      }
      if(this.dialogForm && this.searchInputTreeCheckType=="单选"){
        this.dialogForm.typeName=nameArr.join()
        this.dialogForm.typeId=idArr.join()
      }
      if(this.inFoForm && this.searchInputTreeCheckType=="单选"){
        this.inFoForm.typeName=nameArr.join()
        this.inFoForm.typeId=idArr.join()
      }
      if(this.outsideDialogDialogForm && this.searchInputTreeCheckType=="单选"){
        this.outsideDialogDialogForm.typeName=nameArr.join()
        this.outsideDialogDialogForm.typeId=idArr.join()
      }
    },
    searchInputTreeHide(){
      this.searchInputTreeFilterText=""
    },
    searchInputTreeShow(treeType,formName,type){
      this.searchInputTreeCheckType=treeType
      this.searchInputTreeFormName=formName
      let goodsCategory=""
      if(type=='资产'){//1000资产, 1001耗材
        goodsCategory="1000"
      }else if(type=='耗材'){
        goodsCategory="1001"
      }else{
        goodsCategory=""
      }
      this.listGoodsTypeTreeData(goodsCategory)
    },



  },




}
